﻿using System.Data;
using System.Data.Common;
using System.Xml;

namespace Portal.Workflow.Model
{
    public interface IDatabase
    {
        string ConnectionString { get; set; }

        #region ExecuteNonQuery
        int ExecuteNonQuery(string commandText);
        int ExecuteNonQuery(string commandText, CommandType commandType);
        int ExecuteNonQuery(string commandText, DatabaseParamCls[] commandParameters);
        int ExecuteNonQuery(string commandText, DatabaseParamCls[] commandParameters, CommandType commandType);

        int ExecuteNonQuery(string connectionString, string commandText);
        int ExecuteNonQuery(string connectionString, string commandText, CommandType commandType);
        int ExecuteNonQuery(string connectionString, string commandText, DatabaseParamCls[] commandParameters);
        int ExecuteNonQuery(string connectionString, string commandText, DatabaseParamCls[] commandParameters, CommandType commandType);
       
        int ExecuteNonQuery(DbTransaction transaction, string commandText);
        int ExecuteNonQuery(DbTransaction transaction, string commandText, CommandType commandType);
        int ExecuteNonQuery(DbTransaction transaction, string commandText, DatabaseParamCls[] commandParameters);
        int ExecuteNonQuery(DbTransaction transaction, string commandText, DatabaseParamCls[] commandParameters, CommandType commandType);
        #endregion ExecuteNonQuery

        #region ExecuteReader
        DbDataReader ExecuteReader(string commandText);
        DbDataReader ExecuteReader(string commandText, CommandType commandType);
        DbDataReader ExecuteReader(string commandText, DatabaseParamCls[] commandParameters);
        DbDataReader ExecuteReader(string commandText, DatabaseParamCls[] commandParameters, CommandType commandType);

        DbDataReader ExecuteReader(string connectionString, string commandText);
        DbDataReader ExecuteReader(string connectionString, string commandText, CommandType commandType);
        DbDataReader ExecuteReader(string connectionString, string commandText, DatabaseParamCls[] commandParameters);
        DbDataReader ExecuteReader(string connectionString, string commandText, DatabaseParamCls[] commandParameters, CommandType commandType);

        DbDataReader ExecuteReader(DbTransaction transaction, string commandText);
        DbDataReader ExecuteReader(DbTransaction transaction, string commandText, CommandType commandType);
        DbDataReader ExecuteReader(DbTransaction transaction, string commandText, DatabaseParamCls[] commandParameters);
        DbDataReader ExecuteReader(DbTransaction transaction, string commandText, DatabaseParamCls[] commandParameters, CommandType commandType);
        #endregion ExecuteReader

        #region ExecuteScalar
        object ExecuteScalar(string commandText);
        object ExecuteScalar(string commandText, CommandType commandType);
        object ExecuteScalar(string commandText,  DatabaseParamCls[] commandParameters);
        object ExecuteScalar(string commandText,  DatabaseParamCls[] commandParameters, CommandType commandType);

        object ExecuteScalar(string connectionString, string commandText);
        object ExecuteScalar(string connectionString, string commandText, CommandType commandType);
        object ExecuteScalar(string connectionString,  string commandText,  DatabaseParamCls[] commandParameters);
        object ExecuteScalar(string connectionString, string commandText, DatabaseParamCls[] commandParameters, CommandType commandType);

        object ExecuteScalar(DbTransaction transaction, string commandText);
        object ExecuteScalar(DbTransaction transaction, string commandText, CommandType commandType);
        object ExecuteScalar(DbTransaction transaction, string commandText, DatabaseParamCls[] commandParameters);
        object ExecuteScalar(DbTransaction transaction, string commandText, DatabaseParamCls[] commandParameters, CommandType commandType);
        #endregion ExecuteScalar

        #region ExecuteXmlReader
        XmlReader ExecuteXmlReader(string commandText);
        XmlReader ExecuteXmlReader(string commandText, CommandType commandType);
        XmlReader ExecuteXmlReader(string commandText,  DatabaseParamCls[] commandParameters);
        XmlReader ExecuteXmlReader(string commandText, DatabaseParamCls[] commandParameters, CommandType commandType);

        XmlReader ExecuteXmlReader(DbTransaction transaction, string commandText);
        XmlReader ExecuteXmlReader(DbTransaction transaction, string commandText, CommandType commandType);
        XmlReader ExecuteXmlReader(DbTransaction transaction, string commandText, DatabaseParamCls[] commandParameters);
        XmlReader ExecuteXmlReader(DbTransaction transaction, string commandText, DatabaseParamCls[] commandParameters, CommandType commandType);
        #endregion ExecuteXmlReader

        #region FillDataset
        void FillDataset(string commandText, DataSet dataSet, string[] tableNames);
        void FillDataset(string commandText, DataSet dataSet, string[] tableNames, CommandType commandType);
        void FillDataset(string commandText, DataSet dataSet, string[] tableNames, DatabaseParamCls[] commandParameters);
        void FillDataset(string commandText, DataSet dataSet, string[] tableNames, DatabaseParamCls[] commandParameters, CommandType commandType);

        void FillDataset(string connectionString, string commandText, DataSet dataSet, string[] tableNames);
        void FillDataset(string connectionString, string commandText, DataSet dataSet, string[] tableNames, CommandType commandType);
        void FillDataset(string connectionString, string commandText, DataSet dataSet, string[] tableNames, DatabaseParamCls[] commandParameters);
        void FillDataset(string connectionString, string commandText, DataSet dataSet, string[] tableNames, DatabaseParamCls[] commandParameters, CommandType commandType);

        void FillDataset(DbTransaction transaction, string commandText, DataSet dataSet, string[] tableNames);
        void FillDataset(DbTransaction transaction, string commandText, DataSet dataSet, string[] tableNames, CommandType commandType);
        void FillDataset(DbTransaction transaction,  string commandText, DataSet dataSet, string[] tableNames,  DatabaseParamCls[] commandParameters);
        void FillDataset(DbTransaction transaction, string commandText, DataSet dataSet, string[] tableNames, DatabaseParamCls[] commandParameters, CommandType commandType);
        #endregion

        #region Insert, Update, Delete
        void ExecuteInsertQuery(string tableName, DatabaseParamCls[] commandParameters);
        void ExecuteInsertQuery(DbTransaction transaction, string tableName, DatabaseParamCls[] commandParameters);
        void ExecuteInsertQuery(string connectionString, string tableName, DatabaseParamCls[] commandParameters);

        bool ExecuteUpdateQuery(string tableName, string KeyField, string KeyValue, DatabaseParamCls[] commandParameters);
        bool ExecuteUpdateQuery(DbTransaction transaction, string tableName, string KeyField, string KeyValue, DatabaseParamCls[] commandParameters);
        bool ExecuteUpdateQuery(string connectionString, string tableName, string KeyField, string KeyValue, DatabaseParamCls[] commandParameters);

        bool ExecuteDeleteQuery(string tableName, string KeyField, string KeyValue);
        bool ExecuteDeleteQuery(DbTransaction transaction, string tableName, string KeyField, string KeyValue);
        bool ExecuteDeleteQuery(string connectionString, string tableName, string KeyField, string KeyValue);
        #endregion

        DataTable GetRecordSet(string commandText);
        DataTable GetRecordSet(string commandText, CommandType commandType);
        DataTable GetRecordSet(string commandText, DatabaseParamCls[] commandParameters);
        DataTable GetRecordSet(string commandText, DatabaseParamCls[] commandParameters, CommandType commandType);

        DataTable GetRecordSet(DbTransaction transaction, string commandText);
        DataTable GetRecordSet(DbTransaction transaction, string commandText, CommandType commandType);
        DataTable GetRecordSet(DbTransaction transaction, string commandText, DatabaseParamCls[] commandParameters);
        DataTable GetRecordSet(DbTransaction transaction, string commandText, DatabaseParamCls[] commandParameters, CommandType commandType);

        DataSet GetRecordSetByDataSet(string commandText);
        DataSet GetRecordSetByDataSet(string commandText, CommandType commandType);
        DataSet GetRecordSetByDataSet(string commandText, DatabaseParamCls[] commandParameters);
        DataSet GetRecordSetByDataSet(string commandText, DatabaseParamCls[] commandParameters, CommandType commandType);

        DataSet GetRecordSetByDataSet(DbTransaction transaction, string commandText);
        DataSet GetRecordSetByDataSet(DbTransaction transaction, string commandText, CommandType commandType);
        DataSet GetRecordSetByDataSet(DbTransaction transaction, string commandText, DatabaseParamCls[] commandParameters);
        DataSet GetRecordSetByDataSet(DbTransaction transaction, string commandText, DatabaseParamCls[] commandParameters, CommandType commandType);

        DbTransaction BeginTransaction();
        void RollBack(DbTransaction transaction);
        void Commit(DbTransaction transaction);
        string GetValueAsString(DataRow dr, string FieldName);
        int GetValueAsInt(DataRow dr, string FieldName);
        bool GetValueAsBoolean(DataRow dr, string FieldName);
        decimal GetValueAsDecimal(DataRow dr, string FieldName);
        object GetValueAsObject(DataRow dr, string FieldName);
    }
}
